﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using Models;
using BLL;

namespace PCCS.Management.AdminManage
{
    public partial class CompetControl : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DisplayRoleRightMenu();//显示角色权限菜单
            }
        }


        /// <summary>
        /// 显示所有的子节点信息
        /// </summary>
        protected void DisplayRoleRightMenu()
        {
            //得到父节点的值
            int nodeId = int.Parse(hidParentMenu.Value);
            //得到当前角色Id
            int roleId = int.Parse(hidRoleId.Value);

            ArrayList arrRoleChildMenu = new ArrayList();
            //根据角色Id和父节点Id得到RoleRight表中已经存在的子菜单信息
            IList<LeftLink> RoleChildRights = LeftLinkManager.GetLeftLinksByUserID6(roleId, nodeId);
            foreach (LeftLink roleRight in RoleChildRights)
            {
                arrRoleChildMenu.Add(roleRight.TypeID.ToString());
            }

            IList<LeftType> sysFuns = LeftTypeManager.GetLeftTypesByLeftID(nodeId);
            foreach (LeftType sysFun in sysFuns)
            {
                ListItem li = new ListItem();
                li.Value = sysFun.LeftTypeID.ToString();
                li.Text = sysFun.TypeTitle;

                if (arrRoleChildMenu.Contains(li.Value))
                {
                    li.Selected = true;
                }
                chkChildMenu.Items.Add(li);
            }
        }
    }
}